<?php
// <copyright file="AuthenticationType.cs" company="NQtec">
// Copyright (c) 2008, 2009 All Right Reserved, http://www.dqer.com/
// Copyright (c) 2008, 2009 All Right Reserved, http://www.nqtec.com/
//
// This source is part of the DQER library that released under the LGPL.
// Please see the License.txt file for more information.
// All other rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY 
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// </copyright>
// <author>Victor Gatkov</author>
// <email>v.gatkov@nqtec.com</email>
// <email>info@dqer.com</email>
// <date>2008-09-11</date>
// <summary>Contains a base, abstract class for an AuthorisationPolicyProvider</summary>

if(!defined('IN_DQER_003311')){die('');exit;}
   if(!defined('PAGE_TITLE')) define("PAGE_TITLE",DEFAULT_TITLE); //!!!

   if(FORM_SEC=='JS') {
   echo "<script src=\"".JS_PATH."/jq.js\"></script>\r";
//   echo "<script type=\"text/javascript\" src=\"".JS_PATH."/jq.js\"></script>\r";
   echo "<script type=\"text/javascript\">\r";
   echo "$(document).ready(function(){\r";
   echo "$.get(\"".MODULES_PATH."/forms/xb/\",function(txt){\r";
   echo "$(\".xa\").append('<input type=\"hidden\" name=\"xa\" value=\"'+txt+'\" />');\r";
    if (PGID=='signin') echo "$(\".xa\").append('<input type=\"hidden\" name=\"mix\" value=\"\" />');\r";
   echo "$(\".xa\").append('<input type=\"submit\" name=\"Submit\" value=\"Go!\" />');\r";
   echo "});\r";
   echo "});\r";
   echo "</script>\r";
   }
 if (PGID=='signin') {
  if (PASS_ENC) {
   echo "<script src=\"".JS_PATH."/shax.js\"></script>\r";
   echo "<script type=\"text/javascript\">\r";
   echo "function login(form) {\r";
   echo "form['mix'].value = hex_sha256(form['pword'].value);\r";
   if (PASS_ENC_PARANOID) echo "form['mix'].value = hex_sha256(form['mix'].value + ':' + form['xa'].value);\r";
   echo "form['pword'].value = '';\r";
   echo "return true;\r";
   echo "}\r";
   echo "</script>\r";
  }
 }

// change password !!!!!!!!!!!!! actually no need old password !!!!!
 if (PGID=='cp') {
  if (PASS_ENC) {
   echo "<script src=\"".JS_PATH."/shax.js\"></script>\r";
   echo "<script type=\"text/javascript\">\r";
   echo "function login(form) {\r";
   echo "form['mix1'].value = hex_sha256(form['pass'].value);\r";
   echo "form['mix2'].value = hex_sha256(form['pass1'].value);\r";
   echo "form['mix3'].value = hex_sha256(form['pass2'].value);\r";
   echo "form['pass'].value = '';\r";
   echo "form['pass1'].value = '';\r";
   echo "form['pass2'].value = '';\r";
   echo "return true;\r";
   echo "}\r";
   echo "</script>\r";
  }
 }

 if (PGID=='cu') {
  if (PASS_ENC) {
   echo "<script src=\"".JS_PATH."/shax.js\"></script>\r";
   echo "<script type=\"text/javascript\">\r";
   echo "function login(form) {\r";
   echo "form['mix1'].value = hex_sha256(form['pass'].value);\r";
   echo "form['pass'].value = '';\r";
   echo "return true;\r";
   echo "}\r";
   echo "</script>\r";
  }
 }
?>
